/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pojo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jeferson
 */
@Entity
@Table(name = "TB_ESTADO", catalog = "musical", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TbEstado.findAll", query = "SELECT t FROM TbEstado t"),
    @NamedQuery(name = "TbEstado.findByEstCodigo", query = "SELECT t FROM TbEstado t WHERE t.estCodigo = :estCodigo"),
    @NamedQuery(name = "TbEstado.findByEstDescricao", query = "SELECT t FROM TbEstado t WHERE t.estDescricao = :estDescricao"),
    @NamedQuery(name = "TbEstado.findByEstAbr", query = "SELECT t FROM TbEstado t WHERE t.estAbr = :estAbr")})
public class TbEstado implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "EST_CODIGO")
    private Long estCodigo;
    @Basic(optional = false)
    @Column(name = "EST_DESCRICAO")
    private String estDescricao;
    @Basic(optional = false)
    @Column(name = "EST_ABR")
    private String estAbr;
    @OneToMany(mappedBy = "cidCodestado")
    private List<TbCidade> tbCidadeList;

    public TbEstado() {
    }

    public TbEstado(Long estCodigo) {
        this.estCodigo = estCodigo;
    }

    public TbEstado(Long estCodigo, String estDescricao, String estAbr) {
        this.estCodigo = estCodigo;
        this.estDescricao = estDescricao;
        this.estAbr = estAbr;
    }

    public Long getEstCodigo() {
        return estCodigo;
    }

    public void setEstCodigo(Long estCodigo) {
        Long oldEstCodigo = this.estCodigo;
        this.estCodigo = estCodigo;
        changeSupport.firePropertyChange("estCodigo", oldEstCodigo, estCodigo);
    }

    public String getEstDescricao() {
        return estDescricao;
    }

    public void setEstDescricao(String estDescricao) {
        String oldEstDescricao = this.estDescricao;
        this.estDescricao = estDescricao;
        changeSupport.firePropertyChange("estDescricao", oldEstDescricao, estDescricao);
    }

    public String getEstAbr() {
        return estAbr;
    }

    public void setEstAbr(String estAbr) {
        String oldEstAbr = this.estAbr;
        this.estAbr = estAbr;
        changeSupport.firePropertyChange("estAbr", oldEstAbr, estAbr);
    }

    @XmlTransient
    public List<TbCidade> getTbCidadeList() {
        return tbCidadeList;
    }

    public void setTbCidadeList(List<TbCidade> tbCidadeList) {
        this.tbCidadeList = tbCidadeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (estCodigo != null ? estCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbEstado)) {
            return false;
        }
        TbEstado other = (TbEstado) object;
        if ((this.estCodigo == null && other.estCodigo != null) || (this.estCodigo != null && !this.estCodigo.equals(other.estCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.estDescricao;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
